<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header">

</head>
<style>
	.main{
        margin: 16px 0 0 0;
        width:100%;
        height:auto;
    }
    .name{
        font-size: 14px;
        font-weight: bold;
        margin-top: 16px;
        height: 48px;
        line-height: 48px;
        padding-left: 16px;
        color: #3F4F60;
        border-radius: 4px;
        background: #fff;
    }
    .echart-box{
        background: #fff;
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 4px;
    }
    .echart-box{
        clear: both;
        overflow: hidden;
    }
    .echart-box .item{
        float: left;
        width: 31%;
        margin-right: 2.333%;
        border-radius: 4px;
    }
    .echart-box .tit{
        font-size: 18px;
        margin-bottom: 24px;
        color: #06172A;
        position: relative;
        font-weight: bold;
        padding-left: 12px;
    }
    .echart-box .tit:after{
        content: '';
        width: 4px;
        height: 18px;
        background: var(--buttonborder);
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -8px;
    }
    .echart-box .text{
        color: #5a5f72;
        margin: 8px 0;
        position: relative;
        padding-left: 10px;
     }
    .echart-box .text:after{
        content: '';
        width: 4px;
        height: 14px;
        background: #2C82EB;
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -7px;
    }
    .echart-box .num{
        font-size: 30px;
        padding-bottom: 8px;
        border-bottom: 1px solid #ccc;
    }
    .echart-box-two{
        background: none;
        padding: 0px;
        width: 100%;
    }
    .echart-box-two .item{
        padding: 18px;
        background: #fff;
    }
    .numberPeople,.maxScore,.minScore{
        min-width: 250px;
        border-radius: 4px;
        margin-right: 24px;
        text-align: center;
        padding: 23px 16px;
        box-sizing: border-box;
        border: 1px solid var(--buttonborder);
        margin-bottom: 24px;
    }
    #numberPeople,#maxScore,#minScore{
        margin-top: 10px;
        font-weight: bold;
        font-size: 50px;
        color: #06172A;
        margin-bottom: 18px;
        height: 50px;
    }
    .ibox{
        margin-bottom: 20px;
        overflow: hidden;
    }
    .fixed-table-toolbar{
        margin-bottom: 10px;
    }
    .user{
        background: linear-gradient( 180deg, var(--buttonborder) 0%, #FFFFFF 100%);
        min-width: 250px;
    }
    .tallGrade{
        background: linear-gradient( 180deg, var(--buttonborder) 0%, #FFFFFF 100%);
        min-width: 250px;
    }
    .lowGrade{
        background: linear-gradient( 180deg, var(--buttonborder) 0%, #FFFFFF 100%);
        min-width: 250px;
    }
    .pull-left p{
        font-size: 16px;
        color: #333333;
    }
    .bgcoor{
        background: #ffffff;
        padding-top: 20px;
    }
    .pull-left img {
        width: 50%;height: 126px
    }
    .pull-left .content{
        display: flex;
        flex-direction: column;
        align-items:flex-start;
        margin-right: 30px;
        min-width: 120px;

    }
    .ageBox{
        text-align: center;
        padding-top: 10px;
    }
    .myFilterImg{
    filter: var(--myFilter)
    }
    #nationEcharts,#sexEcharts,#ageEcharts,#page1{
        border: 1px solid var(--buttonborder);
    }
    #mydiv1{
        flex-direction: var(--columnAndReverse);
        flex-direction: row;
        flex-wrap: wrap;
    }
</style>
<body class="gray-bg" style="margin-right: 10px">
<div class="wrapper wrapper-content ">
    <p class="name">全国职业院校技能大赛中等职业教育 -- 婴幼儿照护赛项</p>
    <div id="main" class="main">
        <div class="echart-box-one echart-box" style="padding-bottom: 8px">
            <p class="tit">数据概览</p>
            <div class="ibox" style="margin-bottom: 0;display: flex;flex-direction: row;flex-wrap: wrap;">
                <div class="pull-left numberPeople user" style="display: flex;flex: 1; justify-content: space-evenly; align-items: center;min-width: 370px;">
                    <div class="content">
                        <h2 id="numberPeople" class="totalPeople"></h2>
                        <p>竞赛总人数</p>
                    </div>
                    <img class="myFilterImg" alt="竞赛总人数" src="../../../img/cszrs.png" style="width: 196px;height: 126px">
                </div>
                <div class="pull-left maxScore tallGrade" style="display: flex;flex: 1; justify-content: space-evenly; align-items: center;min-width: 370px;">
                    <div class="content">
                        <h2 id="maxScore" class="totalProvince"></h2>
                        <p>参赛省份（个）</p>
                    </div>
                    <img class="myFilterImg" alt="参赛省份" src="../../../img/cssf.png" style="width: 196px;height:126px">
                </div>
                <div class="pull-left minScore lowGrade" style="display: flex;flex: 1; justify-content: space-evenly; align-items: center;min-width: 370px;">
                    <div class="content">
                        <h2 id="minScore" class="totalUnitName"></h2>
                        <p>参赛院校（所）</p>
                    </div>
                    <img class="myFilterImg" alt="参赛院校" src="../../../img/csyx.png" style="width: 196px;height: 126px">

                </div>
            </div>
        </div>
        <div id="mydiv1" style="display: flex;width: 100%;">

            <div class="echart-box-two echart-box" >
                <div class="item" style="width: 49.5%;margin-right: 1%">
                    <p class="tit">民族分布</p>
                    <div id="nationEcharts" style="height:320px;border-radius: 4px"></div>
                </div>
                <div class="item"  style="width: 49.5%;margin-right: 0">
                    <p class="tit">性别占比</p>
                    <div id="sexEcharts" style="height:320px;border-radius: 4px"></div>
                </div>
            </div>
            <div class="echart-box-two echart-box">
                <div class="item" style="width: 49.5%;margin-right: 1%">
                    <p class="tit">年龄统计</p>
                    <div id="ageEcharts" style="height:320px;border-radius: 4px"></div>
                </div>
                <div class="item" style="width: 49.5%;margin-right: 0">
                    <p class="tit">年龄占比</p>
                    <div id="page1" style="height:320px;border-radius: 4px">
                        <p class="ageBox">
                            <span class="averageAge">平均年龄</span>
                            <span class="maximumAge">最大年龄</span>
                            <span class="minimumAge">最小年龄</span>
                        </p>
                        <div id="ageBiliEcharts" style="height:320px;"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script type="text/javascript" >
    var myChart1=null,myChart2=null,myChart3=null,myChart4=null;
    const myColor=window.getComputedStyle(document.body).getPropertyValue('--buttonborder')

    $(function() {

        $.ajax({
            url: "/jzweb/examinationCostStatistic/statisticAnalysisList",
            type: "get",
            data: {
            },
            success: function (r) {
                if(r==null){
                    layer.msg("未查询到数据！");
                }
                else {
                    let getData = r.data
                    $('.totalPeople').html(getData.totalPeople)//竞赛总人数
                    $('.totalProvince').html(getData.totalProvince)//参赛省份（个）
                    $('.totalUnitName').html(getData.totalUnitName)//参赛院校（所）
                    $('.averageAge').html('平均年龄:'+getData.averageAge+'&nbsp;&nbsp;&nbsp;&nbsp;') //平均年龄
                    $('.maximumAge').html('最大年龄:'+getData.maximumAge+'&nbsp;&nbsp;&nbsp;&nbsp;')  //最大年龄
                    $('.minimumAge').html('最小年龄:'+getData.minimumAge) //最小年龄

                    nationEcharts(getData.nationListX,getData.nationListY) //民族
                    sexEcharts(getData.sexPercentage) //性别
                    ageEcharts(getData.ageListX,getData.ageListY)//年龄统计
                    ageBiliEcharts(getData.agePercentage) //年龄占比
                }
            }
        });

        window.onresize=()=>{
            myChart1?.resize()
            myChart2?.resize()
            myChart3?.resize()
            myChart4?.resize()
        }
    })
    function ageBiliEcharts(data){
        var dom = document.getElementById("ageBiliEcharts");
        myChart4 = echarts.init(dom);
        var option;
        option = {
            tooltip: {
                trigger: 'item',
                // formatter: '{b} : {c}人',
                formatter: "{b}: {c} ({d}%)",
            },
            grid: {
                top: '1%', // 控制饼图距离容器顶部的距离
                left: 'center' // 控制饼图水平居中显示
            },
            legend: {//图例
                x : '86%',
                y : 'center',
                itemHeight: 12,                      //修改icon图形大小
                icon: 'circle',                         //图例前面的图标形状
                // textStyle: {                            //图例文字的样式
                //     color: '#a1a1a1',               //图例文字颜色
                //     fontSize: 12                      //图例文字大小
                // }
            },
            series: [
                {
                    name: '',
                    type: 'pie',
                    radius: ['40%', '60%'],
                    avoidLabelOverlap: false,
                    label: {
                        show: false,
                        position: 'center'
                    },
                    labelLine: {
                        show: false
                    },
                    data:data,
                    labelLine:{
                        normal:{
                            length:15,     // 指示线宽度
                            // lineStyle: {
                            //     color: "#595959"    // 指示线颜色
                            // }
                        },
                    },
                    label: {
                        normal: {
                            // 各分区的提示内容
                            // params: 即下面传入的data数组,通过自定义函数，展示你想要的内容和格式
                            formatter: function(params){
                                return params.name+"\n\n"+params.percent+"%";
                            },
                            textStyle: {            // 提示文字的样式
                                color: '#3F4F60',
                                fontSize: 14
                            }
                        }
                    }
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart4.setOption(option);
        }

    }
    function ageEcharts(x,y){
        var dom = document.getElementById("ageEcharts");
        myChart3 = echarts.init(dom);
        var option;
        option = {
            tooltip: {
                trigger: 'item',
                formatter: '{b} : {c}人',
            },
            legend: {show:false},
            grid: {
                left: '3%',
                right: '4%',
                bottom: '20%',
                containLabel: true
            },
            xAxis: {
                type: 'value',
                splitLine:{
                    show:true,
                    lineStyle:{
                        type:'dashed'
                    }
                },
            },
            yAxis: {
                type: 'category',
                data: y,
                axisTick: {
                    alignWithLabel: true
                },
                axisLabel: {
                    color:'#3F4F60',
                },
                axisLine: {
                    lineStyle: {
                        color:myColor
                    }
                },
            },
            series: [
                {
                    data: x,
                    type: 'bar',
                    label: {
                        show: true,
                        position: 'inside', // 控制文本位置，默认为inside，也可选值为left、right、bottom
                        formatter: '{c}人',
                        color:'#fff'
                    },
                    barWidth: '70%',
                    itemStyle: {
                        color: myColor,
                        normal:{
                            barBorderRadius: [0,50,50,0]
                        }
                    }
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart3.setOption(option);
        }
    }
    function sexEcharts(data) {
        var dom = document.getElementById("sexEcharts");
        myChart2 = echarts.init(dom);
        var option;
        option = {
            color: [myColor,'#F69C36'],
            tooltip: {
                trigger: 'item',
            },
            grid: {
                top: '1%', // 控制饼图距离容器顶部的距离
                left: 'center' // 控制饼图水平居中显示
            },
            legend: {//图例
                x : '86%',
                y : 'center',
                itemHeight: 12,                      //修改icon图形大小
                icon: 'circle',
            },
            series: [
                {
                    name: '',
                    type: 'pie',
                    radius: ['40%', '60%'],
                    data: data,
                    labelLine:{
                        normal:{
                            length:15,
                        },
                    },
                    label: {
                        normal: {
                            formatter: function(params){
                                return params.name+"\n\n"+params.percent+"%";
                            },
                            textStyle: {            // 提示文字的样式
                                color: '#3F4F60',
                                fontSize: 14
                            }
                        }
                    }
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart2.setOption(option);
        }

    }
    function nationEcharts(data,y) {
        var dom = document.getElementById("nationEcharts");
        myChart1= echarts.init(dom);
        var option;
        option = {
            tooltip: {
                trigger: 'axis',
                formatter: function (params) {
                    let mytooltip=`${option.xAxis.data[params[0].dataIndex]}：`
                    for (let i = 0; i < params.length; i++) {
                        let item=params[i]
                        mytooltip+=`${item.value}`
                    }
                    return mytooltip
                },
            },
            legend: {
                orient: 'vertical',
                left: 'left',
            },
            grid: {
                top: '18%',
                left: '10%',  // grid布局设置适当调整避免X轴文字只能部分显示
                right: '10%', // grid布局设置适当调整避免X轴文字只能部分显示
                bottom: '15%',
                containLabel: true //防止坐标轴溢出
            },
            xAxis: {
                type: 'category',
                data: data,
                axisTick: {
                    alignWithLabel: true
                },
                axisLine: {
                    lineStyle: {
                        color:myColor
                    }
                },
                axisLabel: {
                    show: true, // 是否显示刻度标签，默认显示
                    interval: 0, // 坐标轴刻度标签的显示间隔，在类目轴中有效；默认会采用标签不重叠的策略间隔显示标签；可以设置成0强制显示所有标签；如果设置为1，表示『隔一个标签显示一个标签』，如果值为2，表示隔两个标签显示一个标签，以此类推。
                    rotate: -60, // 刻度标签旋转的角度，在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠；旋转的角度从-90度到90度
                    inside: false, // 刻度标签是否朝内，默认朝外
                    margin: 16, // 刻度标签与轴线之间的距离
                    //formatter: '{value} ' , // 刻度标签的内容格式器
                    color:'#3F4F60',
                },
            },
            yAxis: {
                show:true,
                type: 'value',
                splitLine:{
                    show:true,
                    lineStyle:{
                        type:'dashed'
                    }
                },
            },
            series: [
                {
                    data: y,
                    type: 'bar',
                    barWidth: '30%',
                    itemStyle: {
                        normal:{
                            barBorderRadius: [50,50,0,0]
                        }
                    }
                }
            ]
        };
        if (option && typeof option === 'object') {
            myChart1.setOption(option);
        }

    }

</script>
</body>
</html>